A Random Chance Approach to Apple’s Interview Question
May 13 2025
Jack Susank
Can you solve Apple’s Coin Interview Question while blindfolded?
You have:
100 coins (90 heads, 10 tails)
You’re blindfolded
You cannot feel which side of the coin is facing up
Goal: Split the coins into two piles with the same number of tails facing up.
Best Solution
Step 1: Select 10 coins at random and move them to the side
Step 2: Flip all 10 of those coins over so that if heads was facing up before, tails is facing up now.
Step 3: Take off your blindfold because you’re done! The number of tails in the pile of 10 coins will always be the same as the number of tails in the pile of 90 coins.
Do 100 coin flips and then separate the coins into two piles of 50.
Sometimes, the number of tails in the left pile will match the number of tails in the right pile, and you will get the job!
Problems
I know my approach doesn’t work every time
I don’t know how often it doesn’t work
Motivating Question: What percent of the time will my approach work by chance?
Simulation Function
# Simulate flipping two piles of coins and checking if # the number of tails matchlibrary(purrr)# Outcome space of a coin flip# 0 -> heads# 1 -> tailscoin_flip <-c(0, 1)# Function to simulate flipping two piles and checking# if they match in tailsflip_coins <-function(pile_size) { left_pile <-sample(coin_flip, size = pile_size, replace =TRUE) right_pile <-sample(coin_flip, size = pile_size, replace =TRUE)# Return 1 if match, 0 otherwise tails_match <-ifelse(sum(left_pile) ==sum(right_pile), 1, 0)return (tails_match)}
Run the simulation many times and return the resulting estimated probability